package com.example.mvvmtemplate.base.viewmodel;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;

import com.example.mvvmtemplate.base.BaseFragment;

public abstract class BaseMVVMFragment<T extends ViewModel> extends BaseFragment {

    public T viewModel;

    public abstract Class<T> getViewModelClass();

    @Override
    public void onActivityCreated(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        viewModel = new ViewModelProvider(requireActivity()).get(getViewModelClass());
    }
}
